package com.epoint.spring.job;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.util.concurrent.TimeUnit;

/**
 * 这是springboot 整合 quartz 的定时器
 */
@Slf4j
@DisallowConcurrentExecution
public class TestJob extends QuartzJobBean {

    @SneakyThrows
    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        log.info("当前TestJob开始执行~~~" + Thread.currentThread().getName());

        TimeUnit.SECONDS.sleep(6);

        log.info("--------------------------------------" + Thread.currentThread().getName());
    }
}
